For Loop in C

Introduction

The for loop is a statement which allows code to be repeatedly executed. A for loop contains three parts: Initialization, Condition, and Increment or Decrement.

Steps of Execution

  1. First, initialize the variable. This executes only once when entering the loop for the first time.
  2. In the second step, check the condition.
  3. In the third step, control goes inside the loop body and executes.
  4. Finally, increase or decrease the value of the variable.
  5. The same process repeats until the condition is false.

For Loop Flowchart

(Insert flowchart here)

For Loop Syntax

for(Initialization; Test Condition; increment/decrement)
{
    Loop Body;
}